<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

	<f:view>
		<f:loadBundle basename="tvseries.Messages" var="msgs" />

		<head>
			<base href="<%=basePath%>" />

			<title><h:outputText value="#{msgs['app.title']}" />
			</title>

			<meta http-equiv="pragma" content="no-cache">
			<meta http-equiv="cache-control" content="no-cache">
			<meta http-equiv="expires" content="0">
			<meta http-equiv="description" content="<h:outputText value="#{msgs['app.description']}"/>">
			<link rel="stylesheet" type="text/css" href="<%=basePath%>styles.css">
		</head>

		<body>
			<h:form id="main">
				<h:panelGrid align="center" columns="2" styleClass="mainview" headerClass="pageHeader" footerClass="pageFooter"
					columnClasses="menuColumn, contentColumn">

					<f:facet name="header">
						<f:subview id="header">
							<c:import url="/view/header.jsp" />
						</f:subview>
					</f:facet>

					<f:subview id="menu">
						<c:import url="/view/menu.jsp" />
					</f:subview>

					<f:subview id="content">
						<%
							/* CONTENT BEGIN */
						%>
						<h:panelGrid columns="1" styleClass="content" headerClass="contentHeader" footerClass="contentFooter">

							<f:facet name="header">
								<h:panelGroup>
									<h:outputText value="#{tvEpisode.title}" styleClass="title" />
									<f:verbatim>
										<hr />
									</f:verbatim>
									<h:messages />
								</h:panelGroup>
							</f:facet>

							<h:panelGrid columns="2" styleClass="centerContent" columnClasses="centerLabelColumn,centerDataColumn">
								<h:commandLink rendered="#{not empty tvEpisode.prevEpisodeId}" value="< PREV" action="#{tvSeries.viewEpisode}" style="color: #000077; font-size: 12px; font-weight: bold; text-decoration: none; padding-right: 40px;">
									<f:param name="episodeId" value="#{tvEpisode.prevEpisodeId}"/>
								</h:commandLink>
								<h:outputText rendered="#{empty tvEpisode.prevEpisodeId}" value="< PREV" style="color: #BBBBBB; font-size: 12px; font-weight: bold; text-decoration: none; padding-right: 40px;" />
								
								<h:commandLink rendered="#{not empty tvEpisode.nextEpisodeId}" value="NEXT >" action="#{tvSeries.viewEpisode}" style="color: #000077; font-size: 12px; font-weight: bold; text-decoration: none; padding-left: 40px;">
									<f:param name="episodeId" value="#{tvEpisode.nextEpisodeId}"/>
								</h:commandLink>
								<h:outputText rendered="#{empty tvEpisode.nextEpisodeId}" value="NEXT >" style="color: #BBBBBB; font-size: 12px; font-weight: bold; text-decoration: none; padding-left: 40px;"/>
							</h:panelGrid>

							<h:panelGrid columns="2" columnClasses="labelColumn,dataColumn">
								<h:outputText value="#{msgs['view.episode.detail.label.imdbid']}" />
								<h:outputLink value="#{tvEpisode.imdbUrl}">
									<h:outputText value="#{tvEpisode.id}" />
								</h:outputLink>
								<h:outputText value="#{msgs['view.episode.detail.label.season']}" />
								<h:outputText value="#{tvEpisode.season}" />
								<h:outputText value="#{msgs['view.episode.detail.label.episode']}" />
								<h:outputText value="#{tvEpisode.episode}" />
								<h:outputText value="#{msgs['view.episode.detail.label.releaseYear']}" />
								<h:outputText value="#{tvEpisode.releaseYear}" />
								<h:outputText value="#{msgs['view.episode.detail.label.airDate']}" />
								<h:outputText value="#{tvEpisode.airDate}" />
								<h:outputText value="#{msgs['view.episode.detail.label.status']}" />
								<h:outputText value="#{tvEpisode.status}" rendered="#{tvEpisode.status eq 'Archived'}" style="color: #000000" />
								<h:outputText value="#{tvEpisode.status}" rendered="#{tvEpisode.status eq 'Available'}" style="color: #007700" />
								<h:outputText value="#{tvEpisode.status}" rendered="#{tvEpisode.status eq 'Ignored'}" style="color: #666666" />
								<h:outputText value="#{tvEpisode.status}" rendered="#{tvEpisode.status eq 'Missing'}" style="color: #770000" />
								<h:outputText value="#{msgs['view.episode.detail.label.changeStatus']}" />
								<h:panelGroup>
									<h:selectOneMenu id="statusChangeSelect" value="#{tvEpisode.newStatus}">
										<f:selectItem itemValue="Archived" itemLabel="Archived"  />
										<f:selectItem itemValue="Automatic" itemLabel="Automatic" />
										<f:selectItem itemValue="Ignored" itemLabel="Ignored" />
									</h:selectOneMenu>
									<h:commandButton value="change status" action="#{tvEpisode.changeStatus}"/>
								</h:panelGroup>
								<h:outputText value="#{msgs['view.episode.detail.label.summary']}" />
								<h:outputText value="#{tvEpisode.summary}" />
							</h:panelGrid>

							<f:verbatim>
								<br />
								<br />
							</f:verbatim>

							<h:panelGrid columns="2" styleClass="content" headerClass="contentHeader" columnClasses="labelColumn,dataColumn">
								<f:facet name="header">
									<h:panelGroup>
										<h:outputText value="#{msgs['view.episode.detail.header.series']}" styleClass="title" />
										<f:verbatim>
											<hr />
										</f:verbatim>
									</h:panelGroup>
								</f:facet>

								<h:outputText value="#{msgs['view.series.detail.label.title']}" />
								<h:commandLink value="#{tvSeries.title}" action="#{tvManager.viewSeries}">
									<f:param name="seriesId" value="#{tvSeries.id}"/>
								</h:commandLink>
								<h:outputText value="#{msgs['view.series.detail.label.imdbid']}" />
								<h:outputLink value="#{tvSeries.imdbUrl}">
									<h:outputText value="#{tvSeries.id}" />
								</h:outputLink>
								<h:outputText value="#{msgs['view.series.detail.label.lastUpdate']}" />
								<h:outputText value="#{tvSeries.lastUpdate}" />
								<h:outputText value="#{msgs['view.series.detail.label.summary']}" />
								<h:outputText value="#{tvSeries.summary}" />
							</h:panelGrid>

						</h:panelGrid>
						<%
							/* CONTENT END */
						%>
					</f:subview>

					<f:facet name="footer">
						<f:subview id="footer">
							<c:import url="/view/footer.jsp" />
						</f:subview>
					</f:facet>

				</h:panelGrid>
			</h:form>
		</body>
	</f:view>

</html>
